package com.zzyl.mapper;

import com.aliyun.iot20180120.models.QueryDeviceDetailRequest;
import com.github.pagehelper.Page;
import com.zzyl.dto.DeviceDto;
import com.zzyl.entity.Device;
import com.zzyl.vo.DeviceDataGraphVo;
import com.zzyl.vo.DeviceVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DeviceMapper {
    int deleteByPrimaryKey(String iotId);

    int insert(Device record);

    int insertSelective(Device record);

    Device selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Device record);

    int updateByPrimaryKey(Device record);

    /**
     * 这是Mybatis Generator拓展插件生成的方法(请勿删除).
     * This method corresponds to the database table device
     *
     * @mbg.generated
     * @author hewei
     */
    int batchInsert(@Param("list") List<Device> list);

    @Select("select count(1) from device where device_name = #{deviceName}")
    Long countByDeviceName(String deviceName);

    Page<DeviceVo> pageQueryDevice(Device device);

    DeviceVo queryDeviceDetail(String iotId);

    void updateDeviceNickname(Device device);

    Device existDeviceById(String iotId);

    List<DeviceDataGraphVo> queryDeviceDataListByDay(String iotId, String fuctionId, String end, String start);


    List<Long> selectNursingIdsByIotIdWithElder(String iotId);

    List<Long> selectNursingIdsByIotIdWithBed(String iotId);

    @Select("select sur.user_id from sys_user_role sur left join sys_role sr on sur.role_id = sr.id \n" +
            "where sr.role_name = #{roleName}")
    public List<Long> selectByRoleName(String roleName);
}